/**
 * 全局样式文件
 * @author Wu.Liang
 * @date 2025-01-21
 */

// 导入主题变量
@import './variables.scss';

// 重置样式
* {
  box-sizing: border-box;
}

// 设置基准字体大小
html {
  font-size: 16px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: $text-color;
  background-color: $background-color;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

// 页面基础样式
page {
  background-color: $background-color;
  min-height: 100vh;
}

// 通用容器
.container {
  padding: 16px;
  max-width: 750px;
  margin: 0 auto;
}

// 卡片样式
.card {
  background-color: $card-background;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  padding: 16px;
  margin-bottom: 16px;
  
  &-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    
    &-title {
      font-size: 16px;
      font-weight: 600;
      color: $text-color;
    }
    
    &-extra {
      font-size: 12px;
      color: $text-color-secondary;
    }
  }
  
  &-body {
    color: $text-color;
  }
  
  &-footer {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid $border-color;
  }
}

// 按钮样式
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.3s ease;
  
  &:disabled {
    opacity: 0.6;
    cursor: not-allowed;
  }
  
  &-primary {
    background-color: $primary-color;
    color: white;
    
    &:hover:not(:disabled) {
      background-color: darken($primary-color, 10%);
    }
  }
  
  &-secondary {
    background-color: $info-color;
    color: white;
    
    &:hover:not(:disabled) {
      background-color: darken($info-color, 10%);
    }
  }
  
  &-success {
    background-color: $success-color;
    color: white;
    
    &:hover:not(:disabled) {
      background-color: darken($success-color, 10%);
    }
  }
  
  &-warning {
    background-color: $warning-color;
    color: white;
    
    &:hover:not(:disabled) {
      background-color: darken($warning-color, 10%);
    }
  }
  
  &-danger {
    background-color: $error-color;
    color: white;
    
    &:hover:not(:disabled) {
      background-color: darken($error-color, 10%);
    }
  }
  
  &-outline {
    background-color: transparent;
    border: 1px solid $border-color;
    color: $text-color;
    
    &:hover:not(:disabled) {
      background-color: $background-color;
    }
  }
  
  &-text {
    background-color: transparent;
    color: $primary-color;
    padding: 4px 8px;
    
    &:hover:not(:disabled) {
      background-color: rgba($primary-color, 0.1);
    }
  }
  
  &-small {
    padding: 4px 8px;
    font-size: 12px;
  }
  
  &-large {
    padding: 12px 24px;
    font-size: 16px;
  }
  
  &-block {
    width: 100%;
  }
  
  &-round {
    border-radius: 20px;
  }
}

// 表单样式
.form {
  &-group {
    margin-bottom: 16px;
  }
  
  &-label {
    display: block;
    margin-bottom: 4px;
    font-size: 14px;
    font-weight: 500;
    color: $text-color;
    
    &-required::before {
      content: '*';
      color: $error-color;
      margin-right: 4px;
    }
  }
  
  &-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid $border-color;
    border-radius: 6px;
    font-size: 14px;
    color: $text-color;
    background-color: white;
    transition: border-color 0.3s ease;
    
    &:focus {
      outline: none;
      border-color: $primary-color;
      box-shadow: 0 0 0 2px rgba($primary-color, 0.2);
    }
    
    &:disabled {
      background-color: $background-color;
      color: $text-color-disabled;
      cursor: not-allowed;
    }
    
    &-error {
      border-color: $error-color;
      
      &:focus {
        border-color: $error-color;
        box-shadow: 0 0 0 2px rgba($error-color, 0.2);
      }
    }
  }
  
  &-textarea {
    @extend .form-input;
    resize: vertical;
    min-height: 80px;
  }
  
  &-select {
    @extend .form-input;
    cursor: pointer;
  }
  
  &-error {
    margin-top: 4px;
    font-size: 12px;
    color: $error-color;
  }
  
  &-help {
    margin-top: 4px;
    font-size: 12px;
    color: $text-color-secondary;
  }
}

// 列表样式
.list {
  background-color: $card-background;
  border-radius: 8px;
  overflow: hidden;
  
  &-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid $border-color;
    
    &:last-child {
      border-bottom: none;
    }
    
    &-content {
      flex: 1;
      margin-right: 12px;
    }
    
    &-title {
      font-size: 14px;
      font-weight: 500;
      color: $text-color;
      margin-bottom: 4px;
    }
    
    &-description {
      font-size: 12px;
      color: $text-color-secondary;
    }
    
    &-extra {
      font-size: 12px;
      color: $text-color-secondary;
    }
    
    &-arrow {
      color: $text-color-disabled;
      font-size: 12px;
    }
  }
}

// 标签样式
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  
  &-primary {
    background-color: rgba($primary-color, 0.1);
    color: $primary-color;
  }
  
  &-success {
    background-color: rgba($success-color, 0.1);
    color: $success-color;
  }
  
  &-warning {
    background-color: rgba($warning-color, 0.1);
    color: $warning-color;
  }
  
  &-danger {
    background-color: rgba($error-color, 0.1);
    color: $error-color;
  }
  
  &-info {
    background-color: rgba($info-color, 0.1);
    color: $info-color;
  }
}

// 徽章样式
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 600;
  color: white;
  background-color: $error-color;
  
  &-primary {
    background-color: $primary-color;
  }
  
  &-success {
    background-color: $success-color;
  }
  
  &-warning {
    background-color: $warning-color;
  }
  
  &-info {
    background-color: $info-color;
  }
}

// 分割线
.divider {
  height: 1px;
  background-color: $border-color;
  margin: 16px 0;
  
  &-vertical {
    width: 1px;
    height: auto;
    margin: 0 16px;
  }
}

// 间距工具类
.m {
  &-0 { margin: 0 !important; }
  &-1 { margin: 4px !important; }
  &-2 { margin: 8px !important; }
  &-3 { margin: 12px !important; }
  &-4 { margin: 16px !important; }
  &-5 { margin: 20px !important; }
  
  &t-0 { margin-top: 0 !important; }
  &t-1 { margin-top: 4px !important; }
  &t-2 { margin-top: 8px !important; }
  &t-3 { margin-top: 12px !important; }
  &t-4 { margin-top: 16px !important; }
  &t-5 { margin-top: 20px !important; }
  
  &b-0 { margin-bottom: 0 !important; }
  &b-1 { margin-bottom: 4px !important; }
  &b-2 { margin-bottom: 8px !important; }
  &b-3 { margin-bottom: 12px !important; }
  &b-4 { margin-bottom: 16px !important; }
  &b-5 { margin-bottom: 20px !important; }
  
  &l-0 { margin-left: 0 !important; }
  &l-1 { margin-left: 4px !important; }
  &l-2 { margin-left: 8px !important; }
  &l-3 { margin-left: 12px !important; }
  &l-4 { margin-left: 16px !important; }
  &l-5 { margin-left: 20px !important; }
  
  &r-0 { margin-right: 0 !important; }
  &r-1 { margin-right: 4px !important; }
  &r-2 { margin-right: 8px !important; }
  &r-3 { margin-right: 12px !important; }
  &r-4 { margin-right: 16px !important; }
  &r-5 { margin-right: 20px !important; }
}

.p {
  &-0 { padding: 0 !important; }
  &-1 { padding: 4px !important; }
  &-2 { padding: 8px !important; }
  &-3 { padding: 12px !important; }
  &-4 { padding: 16px !important; }
  &-5 { padding: 20px !important; }
  
  &t-0 { padding-top: 0 !important; }
  &t-1 { padding-top: 4px !important; }
  &t-2 { padding-top: 8px !important; }
  &t-3 { padding-top: 12px !important; }
  &t-4 { padding-top: 16px !important; }
  &t-5 { padding-top: 20px !important; }
  
  &b-0 { padding-bottom: 0 !important; }
  &b-1 { padding-bottom: 4px !important; }
  &b-2 { padding-bottom: 8px !important; }
  &b-3 { padding-bottom: 12px !important; }
  &b-4 { padding-bottom: 16px !important; }
  &b-5 { padding-bottom: 20px !important; }
  
  &l-0 { padding-left: 0 !important; }
  &l-1 { padding-left: 4px !important; }
  &l-2 { padding-left: 8px !important; }
  &l-3 { padding-left: 12px !important; }
  &l-4 { padding-left: 16px !important; }
  &l-5 { padding-left: 20px !important; }
  
  &r-0 { padding-right: 0 !important; }
  &r-1 { padding-right: 4px !important; }
  &r-2 { padding-right: 8px !important; }
  &r-3 { padding-right: 12px !important; }
  &r-4 { padding-right: 16px !important; }
  &r-5 { padding-right: 20px !important; }
}

// 文本工具类
.text {
  &-left { text-align: left !important; }
  &-center { text-align: center !important; }
  &-right { text-align: right !important; }
  
  &-primary { color: $primary-color !important; }
  &-success { color: $success-color !important; }
  &-warning { color: $warning-color !important; }
  &-danger { color: $error-color !important; }
  &-info { color: $info-color !important; }
  &-secondary { color: $text-color-secondary !important; }
  &-disabled { color: $text-color-disabled !important; }
  
  &-small { font-size: 12px !important; }
  &-normal { font-size: 14px !important; }
  &-large { font-size: 16px !important; }
  &-xl { font-size: 18px !important; }
  
  &-bold { font-weight: 600 !important; }
  &-normal { font-weight: 400 !important; }
  &-light { font-weight: 300 !important; }
}

// 显示工具类
.d {
  &-none { display: none !important; }
  &-block { display: block !important; }
  &-inline { display: inline !important; }
  &-inline-block { display: inline-block !important; }
  &-flex { display: flex !important; }
  &-inline-flex { display: inline-flex !important; }
}

// Flex工具类
.flex {
  display: flex !important;
  
  &-column { flex-direction: column !important; }
  &-row { flex-direction: row !important; }
  
  &-wrap { flex-wrap: wrap !important; }
  &-nowrap { flex-wrap: nowrap !important; }
  
  &-1 { flex: 1 !important; }
  &-auto { flex: auto !important; }
  &-none { flex: none !important; }
  
  &-center { align-items: center !important; }
  &-start { align-items: flex-start !important; }
  &-end { align-items: flex-end !important; }
  &-stretch { align-items: stretch !important; }
  
  &-justify-center { justify-content: center !important; }
  &-justify-start { justify-content: flex-start !important; }
  &-justify-end { justify-content: flex-end !important; }
  &-justify-between { justify-content: space-between !important; }
  &-justify-around { justify-content: space-around !important; }
}

// 响应式设计
@media (max-width: 767px) {
  .container {
    padding: 12px;
  }
  
  .card {
    padding: 12px;
    margin-bottom: 12px;
  }
  
  .btn {
    padding: 6px 12px;
    font-size: 13px;
  }
  
  .form-input {
    padding: 6px 10px;
    font-size: 13px;
  }
}

@media (min-width: 768px) {
  .container {
    padding: 20px;
  }
  
  .card {
    padding: 20px;
    margin-bottom: 20px;
  }
}

// 动画
.fade {
  &-enter-active, &-leave-active {
    transition: opacity 0.3s ease;
  }
  
  &-enter, &-leave-to {
    opacity: 0;
  }
}

.slide {
  &-enter-active, &-leave-active {
    transition: transform 0.3s ease;
  }
  
  &-enter, &-leave-to {
    transform: translateX(-100%);
  }
}

.scale {
  &-enter-active, &-leave-active {
    transition: transform 0.3s ease;
  }
  
  &-enter, &-leave-to {
    transform: scale(0.9);
  }
} 